<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Store::Friendable</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../css/github.css" type="text/css" media="screen" />
<script src="../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        
        <h1>
            <span class="type">Module</span>
            Store::Friendable
            
        </h1>
        <ul class="files">
            
            <li><a href="../../files/app/models/store/friendable_rb.html">app/models/store/friendable.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-agree">agree</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-friend_request">friend_request</a>,
              </li>
            
              
              <li>
                <a href="#method-i-friended-3F">friended?</a>,
              </li>
            
              
              <li>
                <a href="#method-i-friends">friends</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-agree">
            
              <b>agree</b>(friend)
            
            <a href="../../classes/Store/Friendable.html#method-i-agree" name="method-i-agree" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-agree_source')" id="l_method-i-agree_source">show</a>
                
              </p>
              <div id="method-i-agree_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store/friendable.rb, line 9</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">agree</span>(<span class="ruby-identifier">friend</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">transaction</span> <span class="ruby-keyword">do</span>
    (<span class="ruby-identifier">friend_ids</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">friend</span>.<span class="ruby-identifier">id</span>).<span class="ruby-identifier">uniq</span>
    (<span class="ruby-identifier">friend</span>.<span class="ruby-identifier">friend_ids</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">id</span>).<span class="ruby-identifier">uniq</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">save!</span>
    <span class="ruby-identifier">friend</span>.<span class="ruby-identifier">save!</span>
    <span class="ruby-comment"># FriendBroadcastJob.perform_later(friend.id)</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-friend_request">
            
              <b>friend_request</b>(params, friend)
            
            <a href="../../classes/Store/Friendable.html#method-i-friend_request" name="method-i-friend_request" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-friend_request_source')" id="l_method-i-friend_request_source">show</a>
                
              </p>
              <div id="method-i-friend_request_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store/friendable.rb, line 23</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">friend_request</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">friend</span>)
  <span class="ruby-identifier">a</span> = []
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">$redis</span>.<span class="ruby-identifier">get</span>(<span class="ruby-node">&quot;store_friend:#{params[:friend_id]}&quot;</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">present?</span>
    <span class="ruby-identifier">result</span> = <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">result</span>)
    <span class="ruby-identifier">result</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">params</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">a</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">params</span>)
    <span class="ruby-identifier">result</span> = <span class="ruby-identifier">a</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">$redis</span>.<span class="ruby-identifier">set</span>(<span class="ruby-node">&quot;store_friend:#{params[:friend_id]}&quot;</span>, <span class="ruby-identifier">result</span>.<span class="ruby-identifier">uniq</span>)
  <span class="ruby-constant">FriendBroadcastJob</span>.<span class="ruby-identifier">perform_now</span>(<span class="ruby-identifier">friend</span>.<span class="ruby-identifier">id</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-friended-3F">
            
              <b>friended?</b>(friend)
            
            <a href="../../classes/Store/Friendable.html#method-i-friended-3F" name="method-i-friended-3F" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-friended-3F_source')" id="l_method-i-friended-3F_source">show</a>
                
              </p>
              <div id="method-i-friended-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store/friendable.rb, line 19</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">friended?</span>(<span class="ruby-identifier">friend</span>)
  <span class="ruby-identifier">friend_ids</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">friend</span>.<span class="ruby-identifier">id</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-friends">
            
              <b>friends</b>()
            
            <a href="../../classes/Store/Friendable.html#method-i-friends" name="method-i-friends" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-friends_source')" id="l_method-i-friends_source">show</a>
                
              </p>
              <div id="method-i-friends_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store/friendable.rb, line 5</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">friends</span>
  <span class="ruby-constant">Store</span>.<span class="ruby-identifier">friends</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">friend_ids</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>
